package com.tuyrt.`as`.proj.main.http

import android.util.Log
import com.tuyrt.`as`.proj.common.utils.SPUtil
import com.tuyrt.`as`.proj.main.biz.account.AccountManager
import com.tuyrt.hi.library.restful.HiInterceptor

/**
 * author: Administrator on 2021/6/24.
 * desc:
 */
class BizInterceptor : HiInterceptor {

    override fun intercept(chain: HiInterceptor.Chain): Boolean {
        if (chain.isRequestPeriod) {
            val request = chain.request()

            //val boardingPass = SPUtil.getString("boarding_pass") ?: ""
           val boardingPass = AccountManager.getBoardingPass() ?: ""
            request.addHeader("boarding-pass", boardingPass)
            request.addHeader("auth-token", "MTU5Mjg1MDg3NDcwNw11.26==")
            // 已过期
            //request.addHeader("auth-token", "fd82d1e882462e23b8e88aa82198f19")
        } else if (chain.response() != null) {
            Log.d("BizInterceptor", chain.request().endPointUrl())
            Log.d("BizInterceptor", chain.response()!!.rawData)
        }
        return false
    }
}